/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.minhphuong.dal;

import com.minhphuong.entities.Quyen;
import com.minhphuong.entities.TrangThaiHoaDon;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author MINHPHUONG
 */
public class TrangThaiHoaDonDAL {
    public static List<TrangThaiHoaDon> getAllTTHD() {
        List<TrangThaiHoaDon> listTTHD = null;
        Session session = null;

        try {
            session = HelperDAL.GetSession();
            org.hibernate.Transaction tx = session.beginTransaction();
            Query q = session.createQuery("from TrangThaiHoaDon");
            listTTHD = (List<TrangThaiHoaDon>) q.list();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            session.flush();
            session.close();
        }
        return listTTHD;
    }
    public static TrangThaiHoaDon getTrangThaiHoaDonByID(int id) {
        TrangThaiHoaDon tthd = null;
        Session session = null;

        try {
            session = HelperDAL.GetSession();
            org.hibernate.Transaction tx = session.beginTransaction();
            Query q = session.createQuery("from TrangThaiHoaDon where maTthd=:id").setInteger("id", id);
            tthd = (TrangThaiHoaDon) q.list().get(0);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
           
            session.flush();
            session.close();
        }
        return tthd;
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
}
